Socket
Socket
Sign inDemoInstall

prop-types-extra

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prop-types-extra

React PropType Utilities


Version published
Weekly downloads
1.1M
decreased by-4.9%
Maintainers
1
Weekly downloads
 
Created

What is prop-types-extra?

The prop-types-extra npm package provides additional prop type validators that are not included in the core prop-types library. These validators help in defining more complex prop types for React components, making it easier to enforce stricter type checking and improve code quality.

What are prop-types-extra's main functionalities?

all

The 'all' validator ensures that the prop satisfies all the provided validators. In this example, 'myProp' must be a string and one of the specified options ('option1' or 'option2').

const PropTypes = require('prop-types-extra');

MyComponent.propTypes = {
  myProp: PropTypes.all([PropTypes.string, PropTypes.oneOf(['option1', 'option2'])])
};

elementType

The 'elementType' validator checks that the prop is a valid React component type. This can be useful for higher-order components or components that accept other components as props.

const PropTypes = require('prop-types-extra');

MyComponent.propTypes = {
  myProp: PropTypes.elementType
};

deprecated

The 'deprecated' validator allows you to mark a prop as deprecated and provide a message. This is useful for maintaining backward compatibility while guiding developers towards newer APIs.

const PropTypes = require('prop-types-extra');

MyComponent.propTypes = {
  myProp: PropTypes.deprecated(PropTypes.string, 'Use newProp instead.')
};

isRequiredForA11y

The 'isRequiredForA11y' validator ensures that the prop is required for accessibility purposes. This helps in enforcing accessibility best practices in your components.

const PropTypes = require('prop-types-extra');

MyComponent.propTypes = {
  myProp: PropTypes.isRequiredForA11y(PropTypes.string)
};

Other packages similar to prop-types-extra

Keywords

FAQs

Package last updated on 16 Jan 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc